package main

import (
	"fmt"
	"net/http"
	"github.com/gin-gonic/gin"
	"gitee.com/zhanglibin/spike/controller/activity"
	"gitee.com/zhanglibin/spike/controller/user"
	"gitee.com/zhanglibin/spike/conf"
	"gitee.com/zhanglibin/spike/lib/utils"
)

func main() {
	// 日志初始化
	utils.StartLog()

	// 配置文件初始化
	conf.LoadConfig()

	// 初始化引擎
	s := gin.Default()

	// 加载路由
	InitRouters(s)

	// 绑定端口，然后启动应用
	addr := fmt.Sprintf("%s:%d", "0.0.0.0", conf.C.App.Port)
    utils.ListenAndServe(addr, s)
}

func InitRouters(s *gin.Engine) {
	activity.InitRouter(s)
	user.InitRouter(s)
	s.Any("ping", func(c *gin.Context) {
		c.String(http.StatusOK, "ok")
	})
}
 
